package com.dstz.demo.core.manager.impl;

import com.dstz.base.manager.impl.BaseManager;
import com.dstz.demo.core.dao.StationinfoDao;
import com.dstz.demo.core.manager.StationinfoManager;
import com.dstz.demo.core.model.Stationinfo;
import com.dstz.demo.core.model.Stationlineinfo;
import com.dstz.demo.core.model.StationlineinfoStationinfoDoubleVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * 所有站点信息 Manager处理实现类
 * @author aschs
 * @email aschs@qq.com
 * @time 2020-02-16 16:47:53
 */
@Service("stationinfoManager")
public class StationinfoManagerImpl extends BaseManager<String, Stationinfo> implements StationinfoManager {

    @Resource
    private StationinfoDao stationinfoDao;


    /**
     * @param lng 经度
     * @param lat 纬度
     * @return
     */
    public  List<StationlineinfoStationinfoDoubleVO> getSites(BigDecimal lng, BigDecimal lat) {

        /**
         * 返回data信息格式
         */

        List<StationlineinfoStationinfoDoubleVO> lists=new ArrayList<>();


        /**
         * 获取附近站点
         */
        List<Stationinfo> Stationinfos=stationinfoDao.sitesAll(lng,lat);



        /**
         * 获取距离
         */
        List<Double> list=stationinfoDao.distances(lng,lat);






        ;

        for (int i = 0; i < Stationinfos.size(); i++) {
            /**
             * 实体类存入JSON
             */
            StationlineinfoStationinfoDoubleVO ssdvo=new StationlineinfoStationinfoDoubleVO();

            List<Stationlineinfo> Stationlineinfos=stationinfoDao.getLine(Stationinfos.get(i).getStationId());
                //线路好赋值
               ssdvo.setStationId(Stationinfos.get(i).getStationId());
               ssdvo.setStationName(Stationinfos.get(i).getStationName());
               ssdvo.setLat(Stationinfos.get(i).getLat());
               ssdvo.setLng(Stationinfos.get(i).getLng());
               ssdvo.setStationlineinfo(Stationlineinfos);
               ssdvo.setDistances(list.get(i));

                  lists.add(ssdvo);

        }


            return lists;
        }






        }













